#!/usr/bin/python3
# coded by hllovlk 2021/11/23 下午7:36

import xlrd,time
from selenium import webdriver

# 登陆网站
def zhtj_login(drivers,user_id,user_pwd):
    drivers.get('https://zhtj.youth.cn/zhtj/')
    drivers.find_element_by_id('loginId').send_keys(user_id)
    drivers.find_element_by_id('password').send_keys(user_pwd)
    user_yzm = input('Please input your yanking:')
    drivers.find_element_by_id('yzm').send_keys(user_yzm)
    drivers.find_element_by_id('subBut').click()
    return drivers

def get_login_user_info(drivers):
    wb=xlrd.open_workbook('/home/m/res.xls')
    ws=wb.sheet_by_index(0)
    for rows in range(3,ws.nrows):
        if len(ws.row(rows)[1].value):
            if not ws.row(rows)[0].value.startswith('2018'):
                # user_info=(ws.row(rows).value for i in range(1,3))
                # print(user_info)
                user_id=ws.row(rows)[1].value
                user_pwd=ws.row(rows)[2].value
                zhtj_login(drivers,user_id,user_pwd)
                pause=input('Please enter start:')
                if pause != 'start':
                    break
                drivers.find_element_by_xpath('/html/body/div/div/div[1]/div/div/ul[2]/li[4]/a/i').click()
                time.sleep(2)


if __name__ == '__main__':
    driver= webdriver.Chrome()
    driver.maximize_window()
    # driver=zhtj_login(driver)
    get_login_user_info(driver)